<?php
/**
+-----------------------------------------------------------------------+
* @autor tonera <tonera at gmail.com>;
* @since 2008-9-13
* @version $Id: update_1.3.6_1.3.7.php,v 1.3.7 tonera$
* @description	此升级程序主要是升级数据库.仅用于1.3.6升级到1.3.7
+-----------------------------------------------------------------------+
*/
error_reporting(0);
header("Content-Type: text/html; charset=UTF-8");
include_once(dirname(__FILE__) . "/php/config.inc.php");
include_once(CHINO_PATH . "/Chino.php");
include_once CHINO_MODPATH.'/config/config.inc.php';
include_once CHINO_PHPPATH.'/lang/lang_public.php';
$GLOBALS['adodb'] = Chino::getObject('adodb');
include_once CHINO_LIBPATH.'/db_mysql.inc.php';
$GLOBALS['adodb']->debug	= false;

$wow_cfg_lang	= empty($_COOKIE['wow_cfg_lang'])?"zh-cn":$_COOKIE['wow_cfg_lang'];
if(!array_key_exists($wow_cfg_lang, $langTypeArray)) exit('Error cookie.');
include_once(CHINO_PHPPATH .  "/lang/".$wow_cfg_lang."/inslang.inc.php");


if(!empty($_POST['update']) and !empty($_POST['location']) and !empty($_POST['realm'])){
	if(!get_magic_quotes_gpc()) {
		$langtype	= addslashes($_POST['langtype']);
		$location	= addslashes($_POST['location']);
		$realm		= addslashes($_POST['realm']);
	}else {
		$langtype	= ($_POST['langtype']);
		$location	= ($_POST['location']);
		$realm		= ($_POST['realm']);
	}
	$isarmory		= (phpversion() > "5");
	$sql	= array();
	$sql[]	= "ALTER TABLE ".TABLEHEAD."_config ADD UNIQUE (vname)";
	$sql[]	= "CREATE TABLE `".TABLEHEAD."_itemproperty` (  `id` int(8) NOT NULL auto_increment,  `name` varchar(255) NOT NULL default '',  `property` text NOT NULL,  `itemcode` varchar(40) NOT NULL default '',  `istat` tinyint(2) NOT NULL default '0',  `intotime` datetime NOT NULL default '0000-00-00 00:00:00',  `itemid` varchar(50) default NULL,  `dkperid` int(10) default NULL,  `itemfrom` varchar(100) default NULL,  `itemhost` varchar(100) default NULL,  `isup` tinyint(2) NOT NULL default '0',  PRIMARY KEY  (`id`),  UNIQUE KEY `name` (`name`)) TYPE=MyISAM AUTO_INCREMENT=1 ;";
	$sql[]	= "INSERT IGNORE INTO ".TABLEHEAD."_config (vname, value) VALUES ('location', '$location')";
	$sql[]	= "INSERT IGNORE INTO ".TABLEHEAD."_config (vname, value) VALUES ('langtype', '$langtype')";
	$sql[]	= "INSERT IGNORE INTO ".TABLEHEAD."_config (vname, value) VALUES ('realm', '$realm')";
	$sql[]	= "INSERT IGNORE INTO ".TABLEHEAD."_config (vname, value) VALUES ('isarmory', '$isarmory')";
	$link	= $GLOBALS['adodb']->connect(DBHOST, DBUSER, DBPASS, DBNAME);
	if(!$link) {
		echo("Error:can't connect database.");
		exit;
	}

	foreach($sql as $key=>$val) {
		$rs	= $GLOBALS['adodb']->execute($val);
	}

	if(!$rs) {
		echo("Error: can't update.");
	}else {
		echo("升级成功，请删除此升级文件.(OK! Please delete the file.)");
        exit;
	}
}else {
	echo("<h3><font color=\"red\">您现在需要输入下列信息才能继续.(You are need to input some infomation for update.)</font></h3>");
}
?>
<html>
<body>
<div>升级完成后您需要设置images\icons目录下所有目录可写入权限，cache\member和cache\item目录可写入权限。</div>
<br />
<hr />
<form method=post action="">
	<?php echo $inslang['note11']?>
	<select name="langtype" class="input">
	<?php
	foreach ($langTypeArray as $key=>$val){
		echo("<option value=\"".$key."\">".$val."</option>");
	}
	?>
	</select>


	<?php echo $inslang['location']?>
	<select name="location" class="input">
	<?php
	foreach ($locationArray as $key=>$val){
		echo("<option value=\"".$key."\">".$val."</option>");
	}
	?>
	</select>
	<?php echo $inslang['realm']?><input type="text" name="realm"> 
	<input type="submit" name="update">
</form>
</body>
</html>






